package com.zhangck.bos2_0.Service.transit.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhangck.bos2_0.Service.transit.InOutStorageInfoService;
import com.zhangck.bos2_0.dao.Transit.InOutStorageInfoRepository;
import com.zhangck.bos2_0.dao.Transit.TransitInfoRepository;

import cn.itcast.bos.domain.transit.InOutStorageInfo;
import cn.itcast.bos.domain.transit.TransitInfo;

/** 
* @author 上午茶
* @version 创建时间：2018年6月19日 下午10:59:08 
* 类说明 
*/
@Service
@Transactional
public class InOutStorageInfoServiceImpl implements InOutStorageInfoService{

	@Autowired
	private InOutStorageInfoRepository inOutStorageInfoRepository;
	
	@Autowired
	private TransitInfoRepository transitInfoRepository;
	
	@Override
	public void save(String tramsitId, InOutStorageInfo model) {
		inOutStorageInfoRepository.save(model);
		
		TransitInfo transitInfo = transitInfoRepository.findOne(Integer.parseInt(tramsitId));
		
		transitInfo.getInOutStorageInfos().add(model);
		
		if (model.getOperation().equals("到达网点")) {
			transitInfo.setStatus("到达网点");
			
			transitInfo.setOutletAddress(model.getAddress());
		}
	}

}
